<template>
  <div class="bg_view">
    <div class="progress_box">
      <div style="color: #5aadfb">上传证件</div>
      <div class="omit" style="color: #5aadfb">...</div>
      <div style="color: #5aadfb">选择病历</div>
      <div class="omit" style="color: #5aadfb">...</div>
      <div>填写信息</div>
      <div class="omit">...</div>
      <div>支付押金</div>
    </div>
    <div
      class="recordItem"
      v-for="(item, index) in inpatientLsit"
      @click="selectInp(item, index)"
    >
      <div class="recordItem_cell">
        <div class="recordItem_cell_1">就诊科室：</div>
        <div class="recordItem_cell_2">{{ item.patientDept }}</div>
      </div>
      <div class="recordItem_cell">
        <div class="recordItem_cell_1">就诊医生：</div>
        <div class="recordItem_cell_2">{{ item.patientDoctor }}</div>
      </div>
      <!-- <div class="recordItem_cell">
        <div class="recordItem_cell_1">病&nbsp;&nbsp;床&nbsp;号：</div>
        <div class="recordItem_cell_2">{{item.}}</div>
      </div>
      <div class="recordItem_cell">
        <div class="recordItem_cell_1">诊断结果：</div>
        <div class="recordItem_cell_2">{{item.patientPact}}</div>
      </div> -->
      <div class="recordItem_cell">
        <div class="recordItem_cell_1">入院时间：</div>
        <div class="recordItem_cell_2">{{ item.patientinDate }}</div>
      </div>
      <div class="recordItem_cell">
        <div class="recordItem_cell_1">出院时间：</div>
        <div class="recordItem_cell_2">
          {{ item.patientoutDate ? item.patientoutDate : "未出院" }}
        </div>
      </div>

      <img
        src="@/assets/img/selected.png"
        alt=""
        class="recordItem_img"
        v-if="index == selectIndex"
      />
      <img
        src="@/assets/img/no_selected.png"
        alt=""
        class="recordItem_img"
        v-else
      />
    </div>
    <div style="height: 4rem"></div>
    <div class="next_box" @click="nextFun">
      <div>下一步</div>
    </div>
  </div>
</template>
<script>
import { getInpatientInMainInfo } from "@/api/api";
export default {
  data() {
    return {
      selectIndex: null,

      qsdata: {},
      userInfo: {},
      inpatientLsit: [],
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      if (window.localStorage.getItem("copydata")) {
        var copydata = JSON.parse(window.localStorage.getItem("copydata"));
        this.qsdata = copydata;
      }
      if (window.localStorage.getItem("selectIndex")) {
        this.selectIndex = JSON.parse(
          window.localStorage.getItem("selectIndex")
        );
      }
      this.getInpatientInMainInfo();
    },
    getInpatientInMainInfo() {
      var data = {
        hosId: "111",
        operIdcardNo: this.qsdata.idNo,
        patientName: this.qsdata.patientName,
        inpatientNo: this.qsdata.inpatientNo,
      };
      getInpatientInMainInfo(data).then((res) => {
        if (res.code == 200) {
          this.inpatientLsit = res.data.patientInfo;
        }
      });
    },
    selectInp(item, index) {
      if (item.patientoutDate) {
        if (item.hide == "NO") {
          this.selectIndex = index;
          this.qsdata.inpatientSerialNo = item.patientCode;
          this.qsdata.patientDoctor = item.patientDoctor;
          this.qsdata.patientDept = item.patientDept;
          this.qsdata.patientInDate = item.patientinDate;
          this.qsdata.patientOutDate = item.patientoutDate;
        } else {
          alert("结算未满3周无法复印病历");
          this.selectIndex = null;
        }
      } else {
        alert("未出院无法复印病历");
        this.selectIndex = null;
      }
    },

    nextFun() {
      console.log(this.qsdata);
      if (!this.selectIndex && this.selectIndex != 0) {
        alert("未选择住院病历!");
        return;
      }
      this.qsdata.expressReceiver = "";
      this.qsdata.expressPhone = "";
      this.qsdata.expressAddress = "";
      this.qsdata.purpose='';
      window.localStorage.setItem("copydata", JSON.stringify(this.qsdata));
      window.localStorage.setItem("selectIndex", this.selectIndex);
      window.localStorage.removeItem("otherPurpose");
      window.localStorage.removeItem("addressArr");

      this.$router.push({
        path: "/copy_utility",
      });
    },
  },
};
</script>
<style lang="less" scoped>
.progress_box {
  width: calc(~"100% - 2rem");
  height: 2.75rem;
  background-color: #f7fafd;
  display: flex;
  justify-content: space-between;
  /* align-items: center; */
  padding: 0 1rem;
  color: #b6becc;
  font-size: 0.9375rem;
  line-height: 2.75rem;
}
.progress_box .omit {
  line-height: 2.25rem;
}
.recordItem {
  width: calc(~"100% - 2rem");
  padding: 1rem;
  background-color: #fff;
  margin-bottom: 0.75rem;
  position: relative;
  &_img {
    width: 1.0625rem;
    height: 1.0625rem;
    position: absolute;
    top: calc(~"(100% - 1.0625rem) / 2");
    right: 1rem;
  }
  &_cell {
    display: flex;
    font-size: 0.9375rem;
    align-items: center;
    line-height: 1.875rem;
    &_1 {
      width: 5rem;
      color: #949fb4;
    }
    &_2 {
      width: 70%;
    }
  }
}
.next_box {
  width: calc(~"100% - 2rem");
  height: 2.75rem;
  padding: 0 1rem;
  position: fixed;
  bottom: 10px;
}
.next_box > div {
  background: linear-gradient(90deg, #448eff 0%, #66a3ff 100%);
  border-radius: 3px;
  height: 100%;
  width: 100%;
  text-align: center;
  line-height: 2.75rem;
  color: #fff;
}
</style>